package com.spring.schedule_system.utils;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.spring.schedule_system.entity.Schedule1;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class MySchedules {
    /**
     * 使用HashMap
     * @param schedule
     * @return
     */
    public static List<HashMap> findAll(List<Schedule1> schedule) {
        List<Schedule1> schedule1s1 = new ArrayList<>();
        List<Schedule1> schedule1s2 = new ArrayList<>();
        List<Schedule1> schedule1s3 = new ArrayList<>();
        List<Schedule1> schedule1s4 = new ArrayList<>();
        List<Schedule1> schedule1s5 = new ArrayList<>();
        List<Schedule1> schedule1s6 = new ArrayList<>();
        List<Schedule1> schedule1s7 = new ArrayList<>();
        List<Schedule1> schedule1s8 = new ArrayList<>();
        List<Schedule1> schedule1s9 = new ArrayList<>();
        List<Schedule1> schedule1s10 = new ArrayList<>();
        List<Schedule1> schedule1s11 = new ArrayList<>();
        List<HashMap> list = new ArrayList<>();
        List<List<List>> lists = new ArrayList<>();
        List<HashMap> lts = new ArrayList<>();
        for (Schedule1 schedule1 : schedule) {
            if (schedule1.getWeeks()!=null&&schedule1.getWeeks().equals("一") ) {
                schedule1s1.add(schedule1);
            } else if (schedule1.getWeeks()!=null&&schedule1.getWeeks().equals("二")) {
                schedule1s2.add(schedule1);
            } else if (schedule1.getWeeks()!=null&&schedule1.getWeeks().equals("三") ) {
                schedule1s3.add(schedule1);
            } else if (schedule1.getWeeks()!=null&&schedule1.getWeeks().equals("四") ) {
                schedule1s4.add(schedule1);
            } else if (schedule1.getWeeks()!=null&&schedule1.getWeeks().equals("五")) {
                schedule1s5.add(schedule1);
            }
        }
        HashMap<String, List<Schedule1>> hashMap = new HashMap<>();
        hashMap.put("周一", schedule1s1);
        hashMap.put("周二", schedule1s2);
        hashMap.put("周三", schedule1s3);
        hashMap.put("周四", schedule1s4);
        hashMap.put("周五", schedule1s5);
        HashMap<String, HashMap<String, List<Schedule1>>> zhouqi = new HashMap<>();
        zhouqi.put("周期", hashMap);
        for (Schedule1 schedule1 : hashMap.get("周一")) {
            if (schedule1.getNumber_sections().contains("1")||schedule1.getNumber_sections().contains("2")) {
                schedule1s6.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("3")||schedule1.getNumber_sections().contains("4")) {
                schedule1s7.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("5")||schedule1.getNumber_sections().contains("6")) {
                schedule1s8.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("7")||schedule1.getNumber_sections().contains("8")) {
                schedule1s9.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("9")||schedule1.getNumber_sections().contains("10")) {
                schedule1s10.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("11")||schedule1.getNumber_sections().contains("12")) {
                schedule1s11.add(schedule1);
            }
        }
//        list.add(schedule1s6);
//        list.add(schedule1s7);
//        list.add(schedule1s8);
//        list.add(schedule1s9);
//        list.add(schedule1s10);
        HashMap<String, List<Schedule1>> hashMap1 = new HashMap<>();
        hashMap1.put("第1,2节", schedule1s6);
        hashMap1.put("第3,4节", schedule1s7);
        hashMap1.put("第5,6节", schedule1s8);
        hashMap1.put("第7,8节", schedule1s9);
        hashMap1.put("第9,10节", schedule1s10);
        hashMap1.put("第11,12节", schedule1s11);

        schedule1s6 = new ArrayList<>();
        schedule1s7 = new ArrayList<>();
        schedule1s8 = new ArrayList<>();
        schedule1s9 = new ArrayList<>();
        schedule1s10 = new ArrayList<>();
        for (Schedule1 schedule1 : schedule1s2) {
            if (schedule1.getNumber_sections().contains("1")||schedule1.getNumber_sections().contains("2")) {
                schedule1s6.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("3")||schedule1.getNumber_sections().contains("4")) {
                schedule1s7.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("5")||schedule1.getNumber_sections().contains("6")) {
                schedule1s8.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("7")||schedule1.getNumber_sections().contains("8")) {
                schedule1s9.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("9")||schedule1.getNumber_sections().contains("10")) {
                schedule1s10.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("11")||schedule1.getNumber_sections().contains("12")) {
                schedule1s11.add(schedule1);
            }
        }
//        list.add(schedule1s6);
//        list.add(schedule1s7);
//        list.add(schedule1s8);
//        list.add(schedule1s9);
//        list.add(schedule1s10);
        HashMap<String, List<Schedule1>> hashMap2 = new HashMap<>();
        hashMap2.put("第1,2节", schedule1s6);
        hashMap2.put("第3,4节", schedule1s7);
        hashMap2.put("第5,6节", schedule1s8);
        hashMap2.put("第7,8节", schedule1s9);
        hashMap2.put("第9,10节", schedule1s10);
        hashMap2.put("第11,12节", schedule1s11);
        schedule1s6 = new ArrayList<>();
        schedule1s7 = new ArrayList<>();
        schedule1s8 = new ArrayList<>();
        schedule1s9 = new ArrayList<>();
        schedule1s10 = new ArrayList<>();
        for (Schedule1 schedule1 : schedule1s3) {
            if (schedule1.getNumber_sections().contains("1")||schedule1.getNumber_sections().contains("2")) {
                schedule1s6.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("3")||schedule1.getNumber_sections().contains("4")) {
                schedule1s7.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("5")||schedule1.getNumber_sections().contains("6")) {
                schedule1s8.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("7")||schedule1.getNumber_sections().contains("8")) {
                schedule1s9.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("9")||schedule1.getNumber_sections().contains("10")) {
                schedule1s10.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("11")||schedule1.getNumber_sections().contains("12")) {
                schedule1s11.add(schedule1);
            }
        }
//        list.add(schedule1s6);
//        list.add(schedule1s7);
//        list.add(schedule1s8);
//        list.add(schedule1s9);
//        list.add(schedule1s10);
        HashMap<String, List<Schedule1>> hashMap3 = new HashMap<>();
        hashMap3.put("第1,2节", schedule1s6);
        hashMap3.put("第3,4节", schedule1s7);
        hashMap3.put("第5,6节", schedule1s8);
        hashMap3.put("第7,8节", schedule1s9);
        hashMap3.put("第9,10节", schedule1s10);
        hashMap3.put("第11,12节", schedule1s11);

        schedule1s6 = new ArrayList<>();
        schedule1s7 = new ArrayList<>();
        schedule1s8 = new ArrayList<>();
        schedule1s9 = new ArrayList<>();
        schedule1s10 = new ArrayList<>();
        for (Schedule1 schedule1 : schedule1s4) {
            if (schedule1.getNumber_sections().contains("1")||schedule1.getNumber_sections().contains("2")) {
                schedule1s6.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("3")||schedule1.getNumber_sections().contains("4")) {
                schedule1s7.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("5")||schedule1.getNumber_sections().contains("6")) {
                schedule1s8.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("7")||schedule1.getNumber_sections().contains("8")) {
                schedule1s9.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("9")||schedule1.getNumber_sections().contains("10")) {
                schedule1s10.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("11")||schedule1.getNumber_sections().contains("12")) {
                schedule1s11.add(schedule1);
            }
        }
//        list.add(schedule1s6);
//        list.add(schedule1s7);
//        list.add(schedule1s8);
//        list.add(schedule1s9);
//        list.add(schedule1s10);
        HashMap<String, List<Schedule1>> hashMap4 = new HashMap<>();
        hashMap4.put("第1,2节", schedule1s6);
        hashMap4.put("第3,4节", schedule1s7);
        hashMap4.put("第5,6节", schedule1s8);
        hashMap4.put("第7,8节", schedule1s9);
        hashMap4.put("第9,10节", schedule1s10);
        hashMap4.put("第11,12节", schedule1s11);

        schedule1s6 = new ArrayList<>();
        schedule1s7 = new ArrayList<>();
        schedule1s8 = new ArrayList<>();
        schedule1s9 = new ArrayList<>();
        schedule1s10 = new ArrayList<>();
        for (Schedule1 schedule1 : schedule1s5) {
            if (schedule1.getNumber_sections().contains("1")||schedule1.getNumber_sections().contains("2")) {
                schedule1s6.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("3")||schedule1.getNumber_sections().contains("4")) {
                schedule1s7.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("5")||schedule1.getNumber_sections().contains("6")) {
                schedule1s8.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("7")||schedule1.getNumber_sections().contains("8")) {
                schedule1s9.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("9")||schedule1.getNumber_sections().contains("10")) {
                schedule1s10.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("11")||schedule1.getNumber_sections().contains("12")) {
                schedule1s11.add(schedule1);
            }
        }
//        list.add(schedule1s6);
//        list.add(schedule1s7);
//        list.add(schedule1s8);
//        list.add(schedule1s9);
//        list.add(schedule1s10);
        HashMap<String, List<Schedule1>> hashMap5 = new HashMap<>();
        hashMap5.put("第1,2节", schedule1s6);
        hashMap5.put("第3,4节", schedule1s7);
        hashMap5.put("第5,6节", schedule1s8);
        hashMap5.put("第7,8节", schedule1s9);
        hashMap5.put("第9,10节", schedule1s10);
        hashMap5.put("第11,12节", schedule1s11);
//        lists.add(list);
        list.add(hashMap1);
        list.add(hashMap2);
        list.add(hashMap3);
        list.add(hashMap4);
        list.add(hashMap5);
        HashMap<String, List> jieshu = new HashMap<>();
        jieshu.put("节数", list);
        lts.add(zhouqi);
        lts.add(jieshu);
        return lts;
    }


    /**
     * 使用list
     * @param schedule
     * @return
     * @throws IOException
     */
    public List<List<List>>  selectB(List<Schedule1> schedule) throws IOException {
        List<Schedule1> schedule1s1 = new ArrayList<>();
        List<Schedule1> schedule1s2 = new ArrayList<>();
        List<Schedule1> schedule1s3 = new ArrayList<>();
        List<Schedule1> schedule1s4 = new ArrayList<>();
        List<Schedule1> schedule1s5 = new ArrayList<>();
        List<Schedule1> schedule1s6 = new ArrayList<>();
        List<Schedule1> schedule1s7 = new ArrayList<>();
        List<Schedule1> schedule1s8 = new ArrayList<>();
        List<Schedule1> schedule1s9 = new ArrayList<>();
        List<Schedule1> schedule1s10 = new ArrayList<>();
        List<Schedule1> schedule1s11 = new ArrayList<>();
        List<List> list = new ArrayList<>();
        List<List<List>> lists = new ArrayList<>();
        for (Schedule1 schedule1 : schedule) {
            if (schedule1.getWeeks()!=null&&schedule1.getWeeks().equals("一") ) {
//                    System.out.println(schedule1);
                schedule1s1.add(schedule1);
            } else if (schedule1.getWeeks()!=null&&schedule1.getWeeks().equals("二")) {
                schedule1s2.add(schedule1);
            } else if (schedule1.getWeeks()!=null&&schedule1.getWeeks().equals("三") ) {
                schedule1s3.add(schedule1);
            } else if (schedule1.getWeeks()!=null&&schedule1.getWeeks().equals("四") ) {
                schedule1s4.add(schedule1);
            } else if (schedule1.getWeeks()!=null&&schedule1.getWeeks().equals("五")) {
                schedule1s5.add(schedule1);
            }
        }
        for (Schedule1 schedule1 : schedule1s1) {
            if (schedule1.getNumber_sections().contains("1")||schedule1.getNumber_sections().contains("2")) {
                schedule1s6.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("3")||schedule1.getNumber_sections().contains("4")) {
                schedule1s7.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("5")||schedule1.getNumber_sections().contains("6")) {
                schedule1s8.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("7")||schedule1.getNumber_sections().contains("8")) {
                schedule1s9.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("9")||schedule1.getNumber_sections().contains("10")) {
                schedule1s10.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("11")||schedule1.getNumber_sections().contains("12")) {
                schedule1s11.add(schedule1);
            }
        }
        list.add(schedule1s6);
        list.add(schedule1s7);
        list.add(schedule1s8);
        list.add(schedule1s9);
        list.add(schedule1s10);
        list.add(schedule1s11);

        schedule1s6 = new ArrayList<>();
        schedule1s7 = new ArrayList<>();
        schedule1s8 = new ArrayList<>();
        schedule1s9 = new ArrayList<>();
        schedule1s10 = new ArrayList<>();
        schedule1s11 = new ArrayList<>();
        for (Schedule1 schedule1 : schedule1s2) {
            if (schedule1.getNumber_sections().contains("1")||schedule1.getNumber_sections().contains("2")) {
                schedule1s6.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("3")||schedule1.getNumber_sections().contains("4")) {
                schedule1s7.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("5")||schedule1.getNumber_sections().contains("6")) {
                schedule1s8.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("7")||schedule1.getNumber_sections().contains("8")) {
                schedule1s9.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("9")||schedule1.getNumber_sections().contains("10")) {
                schedule1s10.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("11")||schedule1.getNumber_sections().contains("12")) {
                schedule1s11.add(schedule1);
            }
        }
        list.add(schedule1s6);
        list.add(schedule1s7);
        list.add(schedule1s8);
        list.add(schedule1s9);
        list.add(schedule1s10);
        list.add(schedule1s11);

        schedule1s6 = new ArrayList<>();
        schedule1s7 = new ArrayList<>();
        schedule1s8 = new ArrayList<>();
        schedule1s9 = new ArrayList<>();
        schedule1s10 = new ArrayList<>();
        schedule1s11 = new ArrayList<>();
        for (Schedule1 schedule1 : schedule1s3) {
            if (schedule1.getNumber_sections().contains("1")||schedule1.getNumber_sections().contains("2")) {
                schedule1s6.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("3")||schedule1.getNumber_sections().contains("4")) {
                schedule1s7.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("5")||schedule1.getNumber_sections().contains("6")) {
                schedule1s8.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("7")||schedule1.getNumber_sections().contains("8")) {
                schedule1s9.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("9")||schedule1.getNumber_sections().contains("10")) {
                schedule1s10.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("11")||schedule1.getNumber_sections().contains("12")) {
                schedule1s11.add(schedule1);
            }
        }
        list.add(schedule1s6);
        list.add(schedule1s7);
        list.add(schedule1s8);
        list.add(schedule1s9);
        list.add(schedule1s10);
        list.add(schedule1s11);

        schedule1s6 = new ArrayList<>();
        schedule1s7 = new ArrayList<>();
        schedule1s8 = new ArrayList<>();
        schedule1s9 = new ArrayList<>();
        schedule1s10 = new ArrayList<>();
        schedule1s11 = new ArrayList<>();
        for (Schedule1 schedule1 : schedule1s4) {
            if (schedule1.getNumber_sections().contains("1")||schedule1.getNumber_sections().contains("2")) {
                schedule1s6.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("3")||schedule1.getNumber_sections().contains("4")) {
                schedule1s7.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("5")||schedule1.getNumber_sections().contains("6")) {
                schedule1s8.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("7")||schedule1.getNumber_sections().contains("8")) {
                schedule1s9.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("9")||schedule1.getNumber_sections().contains("10")) {
                schedule1s10.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("11")||schedule1.getNumber_sections().contains("12")) {
                schedule1s11.add(schedule1);
            }
        }
        list.add(schedule1s6);
        list.add(schedule1s7);
        list.add(schedule1s8);
        list.add(schedule1s9);
        list.add(schedule1s10);
        list.add(schedule1s11);

        schedule1s6 = new ArrayList<>();
        schedule1s7 = new ArrayList<>();
        schedule1s8 = new ArrayList<>();
        schedule1s9 = new ArrayList<>();
        schedule1s10 = new ArrayList<>();
        schedule1s11 = new ArrayList<>();
        for (Schedule1 schedule1 : schedule1s5) {
            if (schedule1.getNumber_sections().contains("1")||schedule1.getNumber_sections().contains("2")) {
                schedule1s6.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("3")||schedule1.getNumber_sections().contains("4")) {
                schedule1s7.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("5")||schedule1.getNumber_sections().contains("6")) {
                schedule1s8.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("7")||schedule1.getNumber_sections().contains("8")) {
                schedule1s9.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("9")||schedule1.getNumber_sections().contains("10")) {
                schedule1s10.add(schedule1);
            } else if (schedule1.getNumber_sections().contains("11")||schedule1.getNumber_sections().contains("12")) {
                schedule1s11.add(schedule1);
            }
        }
        list.add(schedule1s6);
        list.add(schedule1s7);
        list.add(schedule1s8);
        list.add(schedule1s9);
        list.add(schedule1s10);
        list.add(schedule1s11);
        lists.add(list);


        return lists;

    }
}
